package com.darksides.lendit.manager.impl;

import java.util.logging.Logger;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.darksides.lendit.dao.UserDAO;
import com.darksides.lendit.exceptions.EmailAlreadyUsedException;
import com.darksides.lendit.exceptions.UserNotFoundException;
import com.darksides.lendit.manager.UserManager;
import com.darksides.lendit.resource.model.User;

@Service
public class UserManagerImpl implements UserManager {

	private static final Logger log = Logger.getLogger(UserManagerImpl.class.getName());
	
	@Autowired
	private UserDAO userDAO;

	public UserManagerImpl() {
		log.info("UserManagerImpl - constructor");	
	}
	
	@Override
	public User getUser(Long userId) {
		return userDAO.getUser(userId);
	}

	@Override
	public User createUser(User user) throws EmailAlreadyUsedException {
		return userDAO.createUser(user);
	}

	@Override
	public User deleteUser(Long userId) throws UserNotFoundException {
		return userDAO.deleteUser(userId);
	}

	@Override
	public User updateUser(User user) {
		return userDAO.updateUser(user);
	}
	
}
